#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const int N=1e6+3;
ll n,m,kx[N],ky[N],q[N];
struct Nod{ll y,id;};
vector<Nod>ee[N];
vector<int>ve[N];
bool vis[N],used[N];
void Dfs(int x)
{
	for(Nod t:ee[x])if(!vis[t.y])used[t.id]=1,vis[t.y]=1,Dfs(t.y);
}
struct PreWork
{
	int tim,fa[N],sz[N],dep[N],hson[N],top[N],dfn[N],pos[N],tag[N];
	void Dfs1(int x)
	{
		sz[x]=1;dep[x]=dep[fa[x]]+1;
		for(int y:ve[x])if(y!=fa[x])
		{
			fa[y]=x;Dfs1(y);sz[x]+=sz[y];
			if(sz[hson[x]]<sz[y])hson[x]=y;
		}
	}
	void Dfs2(int x,int tp)
	{
		dfn[++tim]=x;pos[x]=tim;top[x]=tp;
		if(hson[x])Dfs2(hson[x],tp);
		for(int y:ve[x])if(y!=fa[x]&&y!=hson[x])Dfs2(y,y);
	}
	int Lca(int x,int y)
	{
		while(top[x]!=top[y])dep[top[x]]>dep[top[y]]?x=fa[top[x]]:y=fa[top[y]];
		return dep[x]<dep[y]?x:y;
	}
	void Add(int x,int y)
	{
		int z=y;
		while(y!=x)
		{
			if(tag[y]&&dep[tag[y]]<=dep[x])x=tag[y],tag[y]=0;
			y=fa[y];
		}
		tag[z]=x;
	}
	void Init(){Dfs1(1);Dfs2(1,1);}
}Pre;
int Min(int x,int y){return !x?y:!y?x:Pre.dep[x]<Pre.dep[y]?x:y;}
struct Tree
{
	int tr[N*4];
	#define ls (p<<1)
    #define rs (p<<1|1)
    #define mi ((l+r)>>1)
	void Build(int p,int l,int r)
	{
		if(l==r){tr[p]=Pre.tag[Pre.dfn[p]];return;}
		Build(ls,l,mi);Build(rs,mi+1,r);tr[p]=Min(tr[ls],tr[rs]);
	}
	int Ask(int L,int R,int p,int l,int r)
	{
		if(L<=l&&r<=R)return tr[p];
		if(R<=mi)return Ask(L,R,ls,l,mi);
		if(L>mi)return Ask(L,R,rs,mi+1,r);
		return Min(Ask(L,R,ls,l,mi),Ask(L,R,rs,mi+1,r));
	}
}T;
int Ask(int x,int z)
{
	int s=0;
	while(Pre.top[x]!=Pre.top[z])
	    s=Min(s,T.Ask(Pre.pos[Pre.top[x]],Pre.pos[x],1,1,n)),x=Pre.fa[Pre.top[x]];
	return Min(s,T.Ask(Pre.pos[z],Pre.pos[x],1,1,n)); 
}
int main()
{
	cin>>n>>m;int Q;cin>>Q;
	for(int i=1;i<=m;i++)cin>>kx[i]>>ky[i],ee[kx[i]].push_back({ky[i],i});
	Dfs(1);
	for(int i=1;i<=m;i++)if(used[i])ve[kx[i]].push_back(ky[i]),cout<<kx[i]<<" "<<ky[i]<<endl;
	Pre.Init();vector<Nod>cur;
	for(int i=1;i<=m;i++)if(!used[i])cur.push_back({kx[i],ky[i]});
	sort(cur.begin(),cur.end(),[&](Nod A,Nod B){return Pre.dep[A.id]<Pre.dep[B.id];});
	for(Nod t:cur)Pre.Add(t.y,t.id);
	while(Q--)
	{
		int k,len;cin>>k>>len;
		for(int i=1;i<=len;i++)cin>>q[i];
		int lca=q[1],mn=0;
		for(int i=2;i<=len;i++)lca=Pre.Lca(lca,q[i]);
		for(int i=1;i<=len;i++)mn=Min(mn,Ask(q[i],lca));
		cout<<Pre.dep[lca]<<endl;
	}
}
